package zhishu.iceyyy.com.kd_khd.tcp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;



import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import zhishu.iceyyy.com.kd_khd.R;
import zhishu.iceyyy.com.kd_khd.utils.SpfUtils;

/**
 * 设置IP界面
 */
public class SZIP_Activity extends AppCompatActivity {



    @BindView(R.id.ed_tm)
    EditText edTm;
    @BindView(R.id.ed_tm2)
    EditText edTm2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_szdip_);
        ButterKnife.bind(this);
        edTm.setText((String) SpfUtils.get(SZIP_Activity.this, "ip", "192.168.4.1"));
        edTm2.setText((String) SpfUtils.get(SZIP_Activity.this, "duankou", "8080"));


    }

    @OnClick({R.id.img_back, R.id.bt_dj})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.bt_dj:
                if (TextUtils.isEmpty(edTm.getText().toString())) {
                    Toast.makeText(this, "请输入IP", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (TextUtils.isEmpty(edTm2.getText().toString())) {
                    Toast.makeText(this, "请输入端口", Toast.LENGTH_SHORT).show();
                    return;
                }
                SpfUtils.put(SZIP_Activity.this, "ip", edTm.getText().toString());
                SpfUtils.put(SZIP_Activity.this, "duankou", edTm2.getText().toString());
                Toast.makeText(this, "设置成功", Toast.LENGTH_SHORT).show();
                finish();
                break;

        }
    }


}
